<?php
/**
 * File: Borrow.php
 * User: Mr.Yang
 * Date: 2025/3/25 0025
 * Time: 14:56
 * Note:
 */

namespace app\home\controller;

use app\admin\model\Category as CategoryModel;

class Borrow extends Base
{
    public function initialize()
    {
        parent::initialize();
        $this->checkLogin();
    }

    /**
     * Note: 借阅模板
     * User: Mr.Yang
     * @param int $bookid
     * @return mixed
     */
    public function book($bookid=0)
    {
        if (!$bookid) {
            $this->redirect(url('Category/index'));
        }
        $category = CategoryModel::where("is_show", "=", 1)->order('sort', 'asc')->select()->toArray();
        $book = \app\admin\model\Book::where('id', '=', $bookid)->findOrFail();
        $this->assign('book', $book);
        $this->assign('category', $category);
        return $this->fetch();
    }
}